import request from "@/util/request";

export function addFiles(file){
    return request({
        url: '/cd_file/add',
        method: 'post',
        data: file
    })
}

export function deleteFiles(files){
    return request({
        url: '/cd_file/delete_file',
        method: 'post',
        data: files
    })
}

export function listFiles(){
    return request({
        url: '/cd_file/list',
        method: 'get'
    })
}


export function pageFiles(pageNum, pageSize, filePath){
    return request({
        url: '/cd_file/page?pageNum=' + pageNum + '&pageSize=' + pageSize + '&filePath=' + filePath,
        method: 'get'
    })
}

export function searchFiles(pageNum, pageSize, filePath, search){
    return request({
        url: '/cd_file/search_files?pageNum=' + pageNum + '&pageSize=' + pageSize + '&filePath=' + filePath + '&searchContent=' + search,
        method: 'get'
    })
}

export function uploadDir(fileData){
    return request({
        url: '/cd_file/upload_dir',
        method: 'post',
        data: fileData,
    })
}

export function updateFile(file){
    return request({
        url: '/cd_file/upload_file',
        method: 'post',
        data: file
    })
}


export function cdFileDownloadFiles(file){
    return request({
        url: '/cd_file/download_file',
        method: 'post',
        responseType: 'blob',
        data: file
    })
}

export function cdFileDownloadFileList(fileList){
    return request({
        url: '/cd_file/download_files',
        method: 'post',
        data: fileList,
        responseType: 'blob',
    })
}

export function copyOrCutFile(fileList, targetFolder, isCut){
    return request({
        url: '/cd_file/copy_or_cut?target_file=' + targetFolder + '&is_cut=' + isCut,
        method: 'post',
        data: fileList
    })
}

export function cdFileUpdateFileName(file, newFileName){
    return request({
        url: '/cd_file/update_file_name?newFileName=' + newFileName,
        method: 'post',
        data: file
    })
}
